package com.dao;

import com.entity.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

/**
 * @author james-CAO
 * @title: OrdersDao
 * @projectName csm_emall_ssm
 * @description: order持久层
 * @date 2020/10/13 19:41
 */
public interface OrdersDao {

    @Insert("insert into orders(total,amount,status,paytype,name,phone,address,systime,user_id)"
            + "values (#{total},#{amount},#{status},#{paytype},#{name},#{phone},#{address},#{systime},#{userId})")
    @SelectKey(keyProperty = "id" , statement = "SELECT LAST_INSERT_ID()",before = false,resultType = Integer.class)
    public boolean insert(Order order);

    @Select("select * from orders")
    public List<Order> selectList();

    @Select("select * from orders where id=#{id}")
    public Order select(int id);


}
